/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sqlgenerators.search;

import entities.Search;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author damfercer
 */
public class AdvancedSearchSQLGenerator implements SearchSqlGeneratorInterface{
    private String sqlRes;
    private SearchSqlGeneratorInterface personalGenerator;
    private SearchSqlGeneratorInterface languageOrGenerator;
    private SearchSqlGeneratorInterface languageAndGenerator;
    private SearchSqlGeneratorInterface educationalOrGenerator;
    private SearchSqlGeneratorInterface educationalAndGenerator;
    private SearchSqlGeneratorInterface professionalOrGenerator;
    private SearchSqlGeneratorInterface professionalAndGenerator;
    private SearchSqlGeneratorInterface interestOrGenerator;
    private SearchSqlGeneratorInterface interestAndGenerator;
    private SearchSqlGeneratorInterface relocatingOrGenerator;
    private SearchSqlGeneratorInterface relocatingAndGenerator;
    private List<SearchSqlGeneratorInterface> sqlGeneratorList;
    
    public AdvancedSearchSQLGenerator(){
        sqlGeneratorList=new ArrayList<SearchSqlGeneratorInterface>();
        personalGenerator=new PersonalSQLGenerator();
        sqlGeneratorList.add(personalGenerator);
        languageOrGenerator=new LanguageOrResitrictionsSQLGenerator();
        sqlGeneratorList.add(languageOrGenerator);
        languageAndGenerator=new LanguageAndResitrictionsSQLGenerator();
        sqlGeneratorList.add(languageAndGenerator);
        professionalOrGenerator=new ProfessionalOrSQLGenerator();
        sqlGeneratorList.add(professionalOrGenerator);
        professionalAndGenerator=new ProfessionalAndSQLGenerator();
        sqlGeneratorList.add(professionalAndGenerator);
        educationalOrGenerator=new EducationalOrResitrictionsSQLGenerator();
        sqlGeneratorList.add(educationalOrGenerator);
        educationalAndGenerator=new EducationalAndResitrictionsSQLGenerator();
        sqlGeneratorList.add(educationalAndGenerator);
        interestOrGenerator=new InterestOrResitrictionsSQLGenerator();
        sqlGeneratorList.add(interestOrGenerator);
        interestAndGenerator=new InterestAndResitrictionsSQLGenerator();
        sqlGeneratorList.add(interestAndGenerator);
        relocatingOrGenerator=new RelocatingOrResitrictionsSQLGenerator();
        sqlGeneratorList.add(relocatingOrGenerator);
        relocatingAndGenerator=new RelocatingAndResitrictionsSQLGenerator();
        sqlGeneratorList.add(relocatingAndGenerator); 
        
    }
    
    @Override
    public String getSqlFromSearch(Search search) {
        sqlRes="";
        for(SearchSqlGeneratorInterface gen:sqlGeneratorList){
            sqlRes+=gen.getSqlFromSearch(search);
        }
        return sqlRes;
    }

    /**
     * @return the sqlRes
     */
    public String getSqlRes() {
        return sqlRes;
    }

    /**
     * @param sqlRes the sqlRes to set
     */
    public void setSqlRes(String sqlRes) {
        this.sqlRes = sqlRes;
    }
    
}
